{%  extends 'base.html' %}
{% load static %}
{% block content %}
<table class="layui-hide" id="tablea" lay-filter="menu-filter"></table>
{% endblock %}

{% block js %}

<script>
 layui.use('table', function() {
 var table = layui.table;
 //方法级渲染
 table.render({
  elem: '#tablea'
  ,toolbar: '#toolbarDemo'
  ,url:'/cmdb/hostjson'
  , cols: [[
  { type: 'checkbox', fixed: 'left'}
  ,{field:'name', title: '主机名',width:150,sort: true}
  ,{field:'os', title: '系统',width:200,sort: true}
  ,{field:'outip', title: '外网地址',width:150,sort: true}
  ,{field:'inip', title: '内网地址',width:150,sort: true}
  ,{field:'cpu', title: 'cpu',width:50,sort: true}
  ,{field:'mem', title: '内存',width:50,sort: true}
    ,{field:'status', title: '运行状态',width:100}
<!--   ,{field:'create_time', title: '创建时间',width:200,sort: true}-->
    ,{field:'expiry_time', title: '到期时间',width:300,sort: true}
    ,{field:'desc', title: '描述',width:150}
  ]]
  , id: 'testReload'
  , page: true
  , height: 600
  ,request: {
  pageName: 'page' //页码的参数名称，默认：page
  ,limitName:
  'pageSize' //每页数据量的参数名，默认：limit
  ,statusName:'status'//数据状态的字段名称，默认：code
  ,statusCode:200 //成功的状态码，默认：0
  }
 });

  //头工具栏事件
  table.on('toolbar(tablea)', function(obj){
   console(susu);
    var Status = table.checkStatus(obj.config.id);
    switch(obj.event){
      case 'getdeldata':
        var data = Status.data;
        layer.alert(JSON.stringify(data));
      break;
    };
  });

//
 $('#btn').click(function (){
  var inputVal = $('.layui-input').val()
  table.reload('testReload', {
  url: '/cmdb/searchjson'
  ,request: {
   pageName: 'page' //页码的参数名称，默认：page
   ,limitName: 'pageSize' //每页数据量的参数名，默认：limit
  }
  ,where: {
   query : inputVal
  }
  ,page: {
   curr: 1
  }
  });
 })
 })
</script>

{% endblock %}